//
//  BanBu_ThirdAppWebViewController.m
//  BanBu
//
//  Created by Wang Xj on 13-9-13.
//
//

#import "BanBu_ThirdAppWebViewController.h"

@interface BanBu_ThirdAppWebViewController ()

@end

@implementation BanBu_ThirdAppWebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        _webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    if(!IS_IOS_7)
        self.wantsFullScreenLayout = YES;
    CGRect rect = __MainScreenFrame;
    rect.size.height -= 20;
    _webView.frame = rect;
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(0, 0,24, 24)];
    [button setBackgroundImage:[UIImage imageNamed:@"cancelWeb.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(popself:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
-(void)viewWillDisAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    if(!IS_IOS_7)
        self.wantsFullScreenLayout = NO;
}

-(void)setUrlString:(NSString *)urlStr
{
    NSURL *baseUrl = [NSURL URLWithString:urlStr];
    NSURLRequest * request = [NSURLRequest requestWithURL:baseUrl];
    _webView.frame = self.view.frame;
    
    [_webView loadRequest:request];
    [_webView setDelegate:self];
    [self.view addSubview:_webView];
}
-(void)popself:(UIButton *)sender;
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
